package ${codeModel.packageName};

<#list importList?keys as key>
import ${importList[key]};
</#list>	

/**
 * @description ${tableClassModel.tableMemo}
 * @author ${dataSource.author}
 * @date ${time}
 */
@Controller
@RequestMapping(value = "admin/${tableClassModel.classVariableName}")
public class ${ClassName} extends BaseAction{

	@Autowired
	private ${tableClassModel.className}Service ${tableClassModel.classVariableName}Service;
	
	//记录编辑前的值Before_Edit_Value
	public static final String BEV="${tableClassModel.className}_BEV";
	
	
	/**
	 * 列表显示
	 */
	@RequestMapping(value =  SAFEPATH+"/showList")
	public @ResponseBody AjaxResult showList(${tableClassModel.className} ${tableClassModel.classVariableName}, PaginationVO pageVo) {
		return showList(${tableClassModel.classVariableName}Service, ${tableClassModel.classVariableName}, pageVo);
	}
   	
	/**
	 * 新增
	 */   
	@RemoveRequestToken	
   	@RequestMapping(value =  SAFEPATH+"/add${tableClassModel.className}")
	public @ResponseBody AjaxResult add${tableClassModel.className}(${tableClassModel.className} ${tableClassModel.classVariableName}) {
	 	int i=${tableClassModel.classVariableName}Service.add(${tableClassModel.classVariableName});
	 	if(i > 0){
	 		return new AjaxResult(AjaxResult.STATUS_SUCCESS, SystemMessageCode.ADD_SUCCES, "${tableClassModel.tableMemo}");
	 	}else {
			throw new GlobleException(SystemErrorCode.DATA_ADD_FAIL);
		}
	}
	
	
	
	
	
	/**
	 * 修改
	 */   
	@RemoveRequestToken	
   	@RequestMapping(value =  SAFEPATH+"/modify${tableClassModel.className}")
	public @ResponseBody AjaxResult modify${tableClassModel.className}(${tableClassModel.className} ${tableClassModel.classVariableName}) {
	   		${tableClassModel.classVariableName}.set${tableClassModel.primaryKey.methodName}(((${tableClassModel.className})WebUtil.getSessionAttribute(BEV)).get${tableClassModel.primaryKey.methodName}());
	   		AjaxResult result=modify(${tableClassModel.classVariableName}Service, WebUtil.getSessionAttribute(BEV), ${tableClassModel.classVariableName}, "${tableClassModel.tableMemo}");
			WebUtil.removeSessionAttribute(BEV);
			return  result;
	}
	
	
	
	
   	/**
	 * 进入修改界面
	 */   
	@SaveRequestToken
   	@RequestMapping(value =  SAFEPATH+"/editForm")
	public String editForm(${tableClassModel.primaryKey.classType} id) {
		${tableClassModel.className} ${tableClassModel.classVariableName};
		if (id != null) {
			${tableClassModel.classVariableName} = ${tableClassModel.classVariableName}Service.findById(id);
			WebUtil.getRequest().setAttribute("obj", ${tableClassModel.classVariableName});
			WebUtil.setSessionAttribute(BEV, ${tableClassModel.classVariableName});
		}
		return "admin/${tableClassModel.className}-form";
	}
   	
   	
   	/**
	 * 删除
	 */  
 	@RequestMapping(value = SAFEPATH+"/del")
	public @ResponseBody AjaxResult del(String keys) {
		return remove(${tableClassModel.classVariableName}Service, keys);
	}
  
}